package main

import "fmt"

func f() {
	defer func() {
		if e := recover(); e != nil {
			fmt.Println("Recoved in f:", e)
		}
	}()
	fmt.Println("Calling g.")
	g(0)
	fmt.Println("Returned normally from g.")
}

func g(i int) {
	if i > 3 {
		fmt.Println("Panicking!")
		panic(fmt.Sprintf("%v", i))
	}
	defer fmt.Printf("Defer i in g: %d\n", i)
	fmt.Println("g.i is: ", i)
	g(i + 1)
}

func main() {
	f()
	fmt.Println("main() done")
}
